import request from '@/utils/request';
import {ElMessage} from 'element-plus';


/**
 * 用人单位获取登入验证码
 */
export async function getCaptcha() {
    const res = await request.get('/site/hire/company/captchaImage');
    if (res.data.code === 200) {
        return res.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 校验验证码
 * @returns {Promise<any>}
 */
export async function checkCaptcha(params) {
    const res = await request.post('/site/hire/company/check/captchaCode', params);
    if (res.data.code === 200) {
        return res.data;
    }
    return Promise.reject(new Error(res.data.msg));
}

/**
 * 校验短信验证码
 * @param params
 * @returns {Promise<any>}
 */
export async function checkSms(params) {
    const res = await request.post('/site/hire/company/check/checkSms', params);
    if (res.data.code === 200) {
        return res.data;
    }
    return Promise.reject(new Error(res.data.msg));
}